<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<script src="js/jquery.js"></script>
<script src="bootstrap//js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/base.css">

<style>
  html,body{
    background-color: #f1f1f1;
    
  }
</style>
</head>
<body>
  <header id="header" style="position:relative;">
    <div class="header-content">
        <div style="width: 400px;display:flex">
          <img src="img/logo.png" style="width: 96px;">
        </div>
        <div class="qr-code-container">
          <div class="qr-code">
            <!-- 二维码图片 -->
            <img src="img/appcode.png" alt="QR Code" style="width: 128px;">
          </div>
          <p>APP下载</p>
        </div>
    </div>
</header>
<nav>
  <ul id="myList">
    <li id="1"><a href="#home" class="active"><span class="activeSelected"></span>首页</a></li>
    <li id="38"><a href="#news"><span></span>时政</a></li>
    <li id="43"><a href="#contact"><span ></span>天下</a></li>
    <li id="68"><a href="#about"><span ></span>经济</a></li>
    <li id="45"><a href="#about"><span ></span>文化</a></li>
  </ul>
</nav>
<div class="content-wrapper" style="margin: 0 auto;width:1300px">
<section id="content" style="display: flex;">
  <div style="width:930px;">
    <div id="banners" style="margin-top: 50px;background-color:#fff;width:900px;display:flex;justify-content:center;padding:20 0">
      <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel" style="width:860px;">
        
        <ol class="carousel-indicators">
          <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
          <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
          <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
        </ol>

        <div class="carousel-inner">

        </div>

        <a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    </div>
    <div style="width: 100%;margin-top:20px">
      <p class="title">新闻</p>
      <div class="left-content">
        <ul>
          <li>
            <a href="#">
              <div class="left-content-li">
                <div class="left-content-li-img">
                  <img src="img/appcode.png" class="news-img">
                </div>
                <div >
                  <div class="news-title">视频丨洞庭湖大堤决口封堵最新进展：截至8日8时累计进占135.5米</div>
                  <div class="news-other">
                    <span>来源：</span>
                    <span>时间</span>
                  </div>
                </div>
              </div>
            </a>
          </li>
        </ul>

      </div>
    </div>
  </div>
  <div style="width:330px;display:flex;margin-top:50px;flex-direction: column;position: relative;right:-10">
    <div style="width: 100%;">
      <p class="title">专题</p>
      <div class="right-content" id="zt">
        <ul>


        </ul>
      </div>
    </div>

    <div style="width: 100%;">
      <p class="title">视频专辑</p>
      <div class="right-content" id="zj">

        <ul></ul>
      </div>
    </div>
  </div>
</section>
</div>
</body>
<script>
  var page=1
  var arraylist=[]
  getbannerlist()
  getnewslist()
  function getnewslist(e=1){
    console.log(e)
    $.ajax({
          type: "post",
          url: 'https://www.cailianxinwen.com/app/news/getNewsByChanneAndColumnlN?channelid='+e+'&pagenow='+page,
           dataType: "json",
           //jsonp: "jsoncallback",
           success: function (json) {
            arraylist=arraylist.concat(json.datas)
               console.log('aaa======>',json)
               $.each(arraylist, function(index, value){
                _html+='  <li> <a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1">'
                _html+=' <div class="left-content-li">'
                _html+=' <div class="left-content-li-img">'
                _html+='<img src="'+value.titleimg+'" class="news-img"></div> <div >'
                _html+=' <div class="news-title">'+value.title+'</div>'
                _html+=' <div class="news-other">'
                _html+=' <span>'+value.source+'</span>'
                _html+='<span>'+value.posttime+'</span>'
                _html+='  </div>  </div> </div> </a></li>'

                })
              
          $('.left-content ul').html(_html)

                _html=''
           },
           error: function (err) {
               console.log(err.statusText)
               if(err.statusText=='error')
               {                   
                  alert('链接超时')
               }
           }
       });
  }
  function getbannerlist(e=1)
  {
    var _html=''
    var _count=''
      $.ajax({
          type: "post",
          url: 'https://www.cailianxinwen.com/app/news/getFocusNews?channelid='+e,
           dataType: "json",
           //jsonp: "jsoncallback",
           success: function (json) {
      
            if(json.length==0)
            {
                $('#banners').hide()
            }
            else{
              $.each(json, function(index, value){
                if(index==0)
                {
               _html+='<div class="carousel-item active">'
                _html+='<a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1" target="_self"><img src="'+value.titleimg+'" class="d-block w-100" alt="Slide '+(index+1)+'">' 
                _html+='   <div class="carousel-caption d-none d-md-block">'
                _html+='<p class="carousel-title">'+value.title+'</p>'
                _html+=' </div></a></div>'
                _count+=' <li data-target="#carouselExampleCaptions" data-slide-to="'+index+'" class="active"></li>'
                }
                else{
                  _html+='<div class="carousel-item">'
                _html+='<a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1" target="_self"><img src="'+value.titleimg+'" class="d-block w-100" alt="Slide '+(index+1)+'">' 
                _html+='   <div class="carousel-caption d-none d-md-block">'
                _html+='<p class="carousel-title">'+value.title+'</p>'
                _html+=' </div></a></div>'
                _count+=' <li data-target="#carouselExampleCaptions" data-slide-to="'+index+'" class="active"></li>'
                }
           
                })
                $('.carousel-inner').html(_html)
                $('.carousel-indicators').html(_count)
                _html=''
                _count=''
            }



 
           },
           error: function (err) {
               console.log(err.statusText)
               if(err.statusText=='error')
               {                   
                  alert('链接超时')
               }
           }
       });
    
  }
  var _html=''
      
      $.ajax({
          type: "post",
          url: 'https://www.cailianxinwen.com/app/news/getKeyNewsToPolitical',
           dataType: "json",
           //jsonp: "jsoncallback",
           success: function (json) {
               //console.log(json.topicNewsList)
               $.each(json.topicNewsList, function(index, value){
                if(index<4){
                  _html+='<li><a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1"><img src="'+value.titleimg+'"><p>'+value.title+'</p></a></li>'
                }
         
                })
                $('#zt ul').html(_html)
                _html=''
           },
           error: function (err) {
               console.log(err.statusText)
               if(err.statusText=='error')
               {                   
                  alert('链接超时')
               }
           }
       });
       //qita
       $.ajax({
          type: "post",
          url: 'https://www.cailianxinwen.com/app/news/getOtherNews',
           dataType: "json",
           //jsonp: "jsoncallback",
           success: function (json) {
               console.log(json)
               let key1="videoid"
               let key2="titleimg"
               let arr1=[]
               let arr2=[]
               let a=0
               let b=0
               $.each(json, function(index, value){
                if(Object.keys(value).includes(key1)){
                  _html+='<li><a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1"><img src="'+value.screenshot+'"><p>'+value.name+'</p></a></li>'
                }
                if(Object.keys(value).includes(key2)){
                  let _img=value.titleimg.split(',')
                  _html+='<li><a href="https://www.cailianxinwen.com/app/news/shareNewsDetail?newsid='+value.id+'&type=1"><img src="'+_img[0]+'"><p>'+value.title+'</p></a></li>'
                }
                })
       
              $('#zj ul').html(_html)
                _html=''
           },
           error: function (err) {
        
               if(err.statusText=='error')
               {                   
                  alert('链接超时')
               }
           }
       });
       $(window).scroll(function(){//为了保证兼容性，这里取两个值，哪个有值取哪一个　　
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;　　//scrollTop就是触发滚轮事件时滚轮的高度
        //console.log(scrollTop)
        if(scrollTop>151*10*page)
        {
          page++
          getnewslist()
       
        }
      });
      $('#myList li').click(function() {
        var $this = $(this); // 当前被点击的<li>元素
        //alert($this.attr('id')); // 弹出当前<li>的文本内容
          $('#mylist li a').removeClass('active')
          $('#mylist li a span').removeClass('activeSelected')
          $(this).children().addClass('active')
          $(this).children().children().addClass('activeSelected')
          getbannerlist($this.attr('id'))
          page=1
          arraylist=[]
          getnewslist($this.attr('id'))
    
});
</script>
</html>